package com.Test;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Description:
 * Copyright:   Copyright (c)2019
 * Company:     zefu
 *
 * @author: 张李鑫
 * @version: 1.0
 * Create at:   2022-02-10 15:42:04
 * <p>
 * Modification History:
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2022-02-10     张李鑫                     1.0         1.0 Version
 */
public class Synchronized {
    public ThreadPoolExecutor threadPoolExecutor;

    public Synchronized() {

        threadPoolExecutor = new ThreadPoolExecutor(1, 1, 10, TimeUnit.SECONDS
                , new ArrayBlockingQueue<>(100), new ThreadPoolExecutor.CallerRunsPolicy());
    }

    public void add()  {
        for (int i = 0; i < 100; i++) {
            final int a=i;
            threadPoolExecutor.execute(() -> {
                System.out.print(a);
            });
        }
    }
    public void add1() {
        for (int i = 0; i < 100; i++) {
            final int a=i;
            threadPoolExecutor.execute(() -> {
                System.out.print((char) a);
            });
        }
    }


    public static  void add(Integer name){
        name++;
    }

    public static void main(String[] args) {
        Integer a=3;
        System.out.println(a==++a);
        add(a);
        System.out.println(a);

    }
}
